package de.fhdw.hbs.entity.dto;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author stephan
 * DTO for Kunde objects
 */

public class KundeDTO extends BaseDTO {

	private int id;
	private String nachname;
	private String vorname;
	private String anrede;
	private String titel;
	private boolean gk;
	private String strasse;
	private String plz;
	private String ort;
	private String land;
	private String tel;
	private String fax;
	private String mobil;
	private String firma;
	private String email;
	private byte[] pwHash;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNachname() {
		return nachname;
	}

	public void setNachname(String nachname) {
		this.nachname = nachname;
	}

	public String getVorname() {
		return vorname;
	}

	public void setVorname(String vorname) {
		this.vorname = vorname;
	}

	public String getAnrede() {
		return anrede;
	}

	public void setAnrede(String anrede) {
		this.anrede = anrede;
	}

	public String getTitel() {
		return titel;
	}

	public void setTitel(String titel) {
		this.titel = titel;
	}

	public boolean isGk() {
		return gk;
	}

	public void setGk(boolean gk) {
		this.gk = gk;
	}

	public String getStrasse() {
		return strasse;
	}

	public void setStrasse(String strasse) {
		this.strasse = strasse;
	}

	public String getPlz() {
		return plz;
	}

	public void setPlz(String plz) {
		this.plz = plz;
	}

	public String getOrt() {
		return ort;
	}

	public void setOrt(String ort) {
		this.ort = ort;
	}

	public String getLand() {
		return land;
	}

	public void setLand(String land) {
		this.land = land;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getMobil() {
		return mobil;
	}

	public void setMobil(String mobil) {
		this.mobil = mobil;
	}

	public String getFirma() {
		return firma;
	}

	public void setFirma(String firma) {
		this.firma = firma;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public byte[] getPwHash() {
		return pwHash;
	}

	public void setPwHash(byte[] pwHash) {
		this.pwHash = pwHash;
	}

	public void setPwHash(String password) throws NoSuchAlgorithmException {
		String algorithm = "SHA";
		MessageDigest md = MessageDigest.getInstance(algorithm);

		this.pwHash = md.digest(password.getBytes());

		/*
		 * Print password hash for ( byte b : digest ) { System.out.printf(
		 * "%02x", b ); }
		 */
	}

	public KundeDTO() {
		super();
	}

	public KundeDTO(int id, String nachname, String vorname, String anrede, String titel, boolean gk, String strasse,
			String plz, String ort, String land, String tel, String fax, String mobil, String firma, String email,
			byte[] pwHash) {
		super();
		this.id = id;
		this.nachname = nachname;
		this.vorname = vorname;
		this.anrede = anrede;
		this.titel = titel;
		this.gk = gk;
		this.strasse = strasse;
		this.plz = plz;
		this.ort = ort;
		this.land = land;
		this.tel = tel;
		this.fax = fax;
		this.mobil = mobil;
		this.firma = firma;
		this.email = email;
		this.pwHash = pwHash;
	}

}
